package com.mallcloud.mall.app.api.entity.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

@ApiModel(value = "WxPay2UnifiedOrderResponseVO", description = "微信2统一支付")
@Data
public class WxPay2UnifiedOrderResponseVO implements Serializable {
	private static final long serialVersionUID = 1L;

	private static final String SUCCESS_CODE = "SUCCESS";

	@ApiModelProperty("请求返回code")
	@JSONField(name = "return_code")
	@JsonProperty(value = "return_code")
    private String returnCode;

	@ApiModelProperty("请求返回消息")
	@JSONField(name = "return_msg")
	@JsonProperty(value = "return_msg")
    private String returnMsg;

	@ApiModelProperty("预支付交易会话标识")
	@JSONField(name = "prepay_id")
	@JsonProperty(value = "prepay_id")
    private String prepayId;

	@JsonIgnore
	@JSONField(serialize = false)
	public Boolean isSuccess(){
		return SUCCESS_CODE.equals(this.returnCode);
	}


	@ApiModelProperty("APIv2密钥")
	private String appKey;
	@ApiModelProperty("应用编号")
	private String appId;
	@ApiModelProperty("唤起支付请求参数")
	private SignObj signObj;

	@ApiModel(value = "SignObj", description = "微信2唤起支付参数")
	@Data
	public static class SignObj {

		private String nonceStr;
		private String timeStamp;
		private String appId;
		@JSONField(name = "package")
		private String packageObj;
		private String signType;
		private String paySign;

		public SignObj(String nonceStr, String timeStamp, String appId, String packageObj, String signType) {
			this.nonceStr = nonceStr;
			this.timeStamp = timeStamp;
			this.appId = appId;
			this.packageObj = packageObj;
			this.signType = signType;
		}
	}
}
